#ifndef OPENNAVREVERSEGEOCODINGSERVICEPROVIDER_H_
#define OPENNAVREVERSEGEOCODINGSERVICEPROVIDER_H_

#include <FBase.h>
#include <FLocations.h>
#include <Opennav.h>
#include "OpennavMap.h"

using namespace Osp::Base::Runtime;

class IOpennavReverseGeocodeListener {
public:
	virtual void OnReverseGeocodeResultReceived(opennav::Road& road, opennav::RoadSegment& roadSegment, opennav::RoadJunction& nextJunction, Osp::Locations::Coordinates& coordinate) = 0;
	virtual void OnNoReverseGeocodeResultReceived() = 0;
};

class OpennavReverseGeocodingServiceProvider : private Osp::Base::Runtime::IRunnable {
public:
	OpennavReverseGeocodingServiceProvider();
	~OpennavReverseGeocodingServiceProvider();
	result Construct(OpennavMap* map);
	void ReverseGeocodeRoad(const Osp::Locations::Coordinates& coordinate, IOpennavReverseGeocodeListener& listener);

public:
	Osp::Base::Object* Run(void);

private:
	OpennavMap* __pMap;
	Osp::Base::Runtime::Thread* __pGeocodingWorker;
	Osp::Base::Runtime::Mutex* __pLock;
	IOpennavReverseGeocodeListener* __pRequestListener;
	bool __kill;
	bool __activate;
	Osp::Locations::Coordinates __coordinate;
};

#endif
